<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:include href="/content/xsl/main.xsl" />

  <xsl:template match="content">
    <xsl:apply-templates select="announcement" />
  </xsl:template>

  <xsl:template match="announcement">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="posts|media">
    <div class="block" id="{@type}-block">
      <div class="header">
        <span class="gray"><xsl:value-of select="../@title" /></span>
        <xsl:if test="0&lt;count(*)">
          <xsl:call-template name="link">
            <xsl:with-param name="url"><xsl:value-of select="concat(//urls/base, '/', name(), '/', @type)" /></xsl:with-param>
            <xsl:with-param name="text">Все</xsl:with-param>
          </xsl:call-template>
        </xsl:if>
      </div>
      <xsl:choose>
        <xsl:when test="0&lt;count(*)">
          <xsl:apply-templates />
        </xsl:when>
        <xsl:otherwise>
          <p class="gray">отсутствуют</p>
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>

  <xsl:template match="post">
    <div class="post-block">
      <xsl:if test="@photo">
        <div class="thumb">
          <img src="{@photo}" alt="" />
        </div>
      </xsl:if>
      <span class="date gray"><xsl:value-of select="@date" /></span>
      <xsl:variable name="url">
        <xsl:value-of select="concat(//urls/base, '/posts/post/', @id)" />
      </xsl:variable>
      <h2 class="post-title">
        <xsl:call-template name="link">
          <xsl:with-param name="url"><xsl:value-of select="$url" /></xsl:with-param>
          <xsl:with-param name="text"><xsl:value-of select="title" /></xsl:with-param>
          <xsl:with-param name="class">anchor black</xsl:with-param>
        </xsl:call-template>
      </h2>
      <a href="{//urls/base}/posts/post/{@id}" class="anchor black link">
        <div class="text">
          <xsl:value-of select="content" disable-output-escaping="yes" />
        </div>
      </a>
      <xsl:apply-templates select="autor" />
      <div class="info gray">Комментариев: <xsl:value-of select="@comments" /></div>
    </div>
  </xsl:template>

  <xsl:template match="post/autor">
    <div class="info gray">
      Автор:
      <xsl:call-template name="profile-link">
        <xsl:with-param name="text"><xsl:value-of select="." /></xsl:with-param>
        <xsl:with-param name="class">anchor gray</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

</xsl:stylesheet>
